/*
 * ICM20602.c
 *
 *  Created on: Jun 9, 2025
 *      Author: 31271
 */
#include "ICM20602.h"
#include "HeadFile.h"

void icm20602_get_acc() {
    // Read accelerometer data from ICM20602
    icm20602_acc_x = ICM20602_Read_Accel_X();
    icm20602_acc_y = ICM20602_Read_Accel_Y();
    icm20602_acc_z = ICM20602_Read_Accel_Z();
}

void icm20602_get_gyro() {
    // Read gyroscope data from ICM20602
    icm20602_gyro_x = ICM20602_Read_Gyro_X();
    icm20602_gyro_y = ICM20602_Read_Gyro_Y();
    icm20602_gyro_z = ICM20602_Read_Gyro_Z();
}

void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi){


    uint32_t itsource = hspi->Instance->CR2;
    uint32_t itflag   = hspi->Instance->SR;

    /* SPI in mode Receiver ----------------------------------------------------*/
    if ((SPI_CHECK_FLAG(itflag, SPI_FLAG_OVR) == RESET) &&
        (SPI_CHECK_FLAG(itflag, SPI_FLAG_RXNE) != RESET) && (SPI_CHECK_IT_SOURCE(itsource, SPI_IT_RXNE) != RESET))
        {
            hspi->RxISR(hspi);
            return;
        }

}